home *** CD-ROM | disk | FTP | other *** search
- // Template to create a picture that contains PostScript
- // which scales as it's drawn
-
- #include "PrintComments.h"
-
- PicHandle DoPicture(void);
- Handle StuffInHandle(const Str255 theString);
-
- /*------ main ----------------------------------------------------------------------------*/
-
- PicHandle myPicture;
-
- main()
-
- {
-
- GrafPort myPort;
-
-
- InitGraf((Ptr) &thePort);
- OpenPort(&myPort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- InitCursor();
-
- myPicture = DoPicture(); // make and publish our picture
-
- } /* main */
-
-
-
-
- /*------ DoPicture ----------------------------------------------------------------------*/
-
- PicHandle DoPicture (void)
-
- {
- Rect myRect;
- PicHandle thePicHandle;
- GrafPort myPort;
- long scrapResult;
- unsigned long thePictureSize;
- PixPatHandle thePixPat;
- short theFont, textSize = 14;
- Handle myHandle;
-
- const Str255 myString =
- "\pclippath pathbbox 4 copy moveto lineto 4 1 roll exch moveto exch lineto stroke\r";
-
- OpenPort(&myPort);
- SetRect(&myRect,0,0,200,200);
- thePicHandle = OpenPicture(&myRect);
- ClipRect(&myRect);
-
- MoveTo(22,22);
- LineTo(55,55);
- LineTo(58,22);
- LineTo(22,58);
-
- GetFNum ("\pTimes", &theFont);
- TextFont (theFont);
- TextSize (textSize);
-
- SetRect(&myRect,50,50,100,150);
- ClipRect(&myRect);
-
- MoveTo(0,0);
- LineTo(0,0); // flush the QuickDraw changes to the clip
-
- PicComment(PostScriptBegin,0,NULL);
- myHandle = StuffInHandle(myString);
- PicComment(PostScriptHandle,myString[0],myHandle);
- DisposHandle(myHandle);
- PicComment(PostScriptEnd,0,NULL);
-
- SetRect(&myRect,0,0,200,200);
- ClipRect(&myRect);
-
- MoveTo(100,50);
- DrawString("\pA wonderful test");
-
- ClosePicture();
- ClosePort(&myPort);
-
- thePictureSize = GetHandleSize((Handle)thePicHandle);
-
- ZeroScrap();
- HLock((Handle)thePicHandle);
- scrapResult = PutScrap(GetHandleSize((Handle)thePicHandle),'PICT',StripAddress(*thePicHandle));
- HUnlock((Handle)thePicHandle);
-
- KillPicture(thePicHandle); // don't forget to clean up after yourself
-
- } /* InitPicture */
-
- /*------ StuffInHandle ----------------------------------------------------------------------*/
-
-
- Handle StuffInHandle(const Str255 theString)
- {
- Handle theHandle = NewHandle(theString[0]);
- HLock(theHandle);
- BlockMove((Ptr)&theString[1],*theHandle,theString[0]);
- HUnlock(theHandle);
- return(theHandle);
- }
-